package com.bj58.mis.apm.server.statistics.service.impl;

import com.bj58.mis.apm.server.statistics.dto.warn.WarnInfo;
import com.bj58.mis.apm.server.statistics.mapper.WarnMapper;
import com.bj58.mis.apm.server.statistics.service.BaseService;
import com.bj58.mis.apm.server.statistics.service.WarnService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: wangxw
 * @Date: 2018/7/2 10:39
 */
@Service
@Transactional
public class WarnServiceImpl extends BaseService<WarnMapper> implements WarnService {
    @Override
    public List<WarnInfo> getWarnList(String userName) {
        List<String> cubeids = this.getAuthCubeIdList(userName);
        if(cubeids != null && cubeids.size() > 0){
            List<WarnInfo> warnList = mapper.getWarnList(cubeids);
            List<WarnInfo> list = mapper.getUnused(cubeids);
            if(list.size() > 0){
                warnList.add(0, new WarnInfo("存在超出30天未查询的cube，请关注。"));
            }
            return warnList;
        }
        return new ArrayList<>();
    }

    @Override
    public void lookover(String userName) {
        List<String> cubeids = this.getAuthCubeIdList(userName);
        if(cubeids != null && cubeids.size() > 0){
            mapper.lookover(cubeids, userName);
        }
    }
}
